package com.wty.basic.objectReference;

import com.wty.basic.pojo.School;
import com.wty.basic.pojo.Student;

/**
 * 两个引用指向一个对象
 */
public class Test2 {

    public static void main(String args[]){
        Student stu1=new Student("wty",18,new School("tust",2000));
        Student stu2=stu1;
        System.out.println("更改前stu2");
        System.out.println(stu2.getName());
        System.out.println(stu2.getAge());
        System.out.println(stu2.getSchool().getName()+stu2.getSchool().getNum());

        /**
         * 更改操作
         */
        School school=new School("testschool",1000);
        stu2.setName("test");
        stu2.setAge(10086);
        stu2.setSchool(school);


        System.out.println("更改后stu2");
        System.out.println(stu2.getName());
        System.out.println(stu2.getAge());
        System.out.println(stu2.getSchool().getName()+stu2.getSchool().getNum());

        System.out.println("更改后stu1");
        System.out.println(stu1.getName());
        System.out.println(stu1.getAge());
        System.out.println(stu1.getSchool().getName()+stu2.getSchool().getNum());



    }
}
